package com.enjoyor.soa.traffic.core.tsms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.enjoyor.soa.traffic.core.tsms.domain.AssessItems;
import com.enjoyor.soa.traffic.core.tsms.mapper.IAssessItemsMapper;
import com.enjoyor.soa.traffic.core.tsms.service.IAssessItemsService;
import com.enjoyor.soa.traffic.frame.logger.IPubLogMapper;
import com.enjoyor.soa.traffic.util.enums.log.LogInfoDic;
import com.enjoyor.soa.traffic.util.helper.TimeHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;


@Service
@Transactional
@SuppressWarnings("rawtypes")
public class AssessItemsService implements IAssessItemsService{

	@Autowired
	private IAssessItemsMapper iAssessItemsMapper;
	
	@Autowired
	private IPubLogMapper iPubLogMapper;
	
	@Override
	public Page getAssessItemsPage(Page page) {
		// TODO Auto-generated method stub
		return iAssessItemsMapper.getAssessItemsPage(page);
	}

	@Override
	public List<AssessItems> getAssessItemsList() {
		// TODO Auto-generated method stub
		return iAssessItemsMapper.getAssessItemsList();
	}

	@Override
	public void addAssessItems(AssessItems assessItems, String personName) {
		// TODO Auto-generated method stub
		String itemsId = "A"+ TimeHelper.getUniqueString();
		assessItems.setItemsId(itemsId);
		iAssessItemsMapper.insertSelective(assessItems);
		iPubLogMapper.saveNoramlLogInfo(personName, null,LogInfoDic.LOG_TRANSTYPE_ENUM.TRANSTYPE_INSERT.getCode(),
                String.format("添加考核项:{%s} 操作成功!", new Object[] { assessItems.getId() }),
                LogInfoDic.LOG_MODULAR_ENUM.TSMS_COMMON_ROUTE_MANAGEMENT.getMessage());
	}

	@Override
	public void editAssessItems(AssessItems assessItems, String personName) {
		// TODO Auto-generated method stub
		iAssessItemsMapper.insertSelective(assessItems);
		iPubLogMapper.saveNoramlLogInfo(personName, null,LogInfoDic.LOG_TRANSTYPE_ENUM.TRANSTYPE_UPDATE.getCode(),
                String.format("修改考核项:{%s} 操作成功!", new Object[] { assessItems.getId() }),
                LogInfoDic.LOG_MODULAR_ENUM.TSMS_COMMON_ROUTE_MANAGEMENT.getMessage());
	}

	@Override
	public void deleteAssessItems(String itemsId, String personName) {
		// TODO Auto-generated method stub
		iPubLogMapper.saveNoramlLogInfo(personName, null,LogInfoDic.LOG_TRANSTYPE_ENUM.TRANSTYPE_DELETE.getCode(),
                String.format("删除考核项:{%s} 操作成功!", new Object[] {itemsId}),
                LogInfoDic.LOG_MODULAR_ENUM.TSMS_COMMON_ROUTE_MANAGEMENT.getMessage());
	}

}
